package com.yycx.module.bus.provider.handler.sbreturn;

import com.yycx.common.base.entity.EntityMap;
import com.yycx.common.mybatis.interceptor.PageInterceptor;
import com.yycx.common.mybatis.model.PageParams;
import com.yycx.common.mybatis.query.CriteriaQuery;
import com.yycx.common.security.OpenHelper;
import com.yycx.module.bus.client.entity.*;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 已申请退垫付明细列表扩展器
 *
 * @author zyf
 */
@Component("yesSbReturnPageListHandler")
public class YesSbReturnPageListHandler implements PageInterceptor<BusOrderDetails> {


    @Override
    public void prepare(CriteriaQuery<BusOrderDetails> cq, PageParams pageParams, EntityMap params) {
        cq.clear();
        Long returnPaymentId = params.getLong("paymentId");
        cq.select(BusOrderDetails.class, "salePrice", "saleNum", "saleAmount","supplierPayBond");
        cq.select(BusOrder.class, "supplierBondType", "customBondType", "sendDate", "orderNo");
        cq.addSelect(BusSupplier.class, "supplierName");
        cq.addSelect(BusCustom.class, "customName");
        cq.addSelect(BusDrugs.class, "drugsName", "drugsSpec");
        cq.eq(BusOrderDetails.class, "orderId");
        cq.eq(true,"bod.companyId", OpenHelper.getCompanyId());
        cq.eq("bod.returnDianfuId", returnPaymentId);
        cq.orderByDesc("bod.createTime");
    }

}
